Repository navigation
Conversation
… creation Generating variations lazily suits a local filesystem, where checking that a file exists is cheap. On a bucket each check is a request, and variations served without the MediaController (through a CDN or pre-signed URLs) are never generated when missing. With cache.store_on_create enabled, a listener converts all the applicable variations when a media is created or moved, forcing the conversion as no variation can be stored at that path yet.
…us is configured The store_on_create_message_bus setting names the bus to dispatch a StoreVariations message to, instead of generating the variations synchronously; routing the message to an asynchronous transport moves the generation to a worker. A setting that names no Messenger bus fails the container compilation.
|
@xavierlacot any spare time to review this improvement to the generation of variations and feature to dispatch that to the background? |
|
@xavierlacot any feedback on decoupling generation from hoth path? |
|
Hi @rvanlaak, sorry for the long silence, and thanks for this. I understand the need covered buy this PR, thanks a lot for trying to give an asnwer on this topic :) My main feedback is about scope. The PR does two things: 1/ it adds a setting that generates variations when a media is created ( I would like to split those 2 things, as I bvelieve that generating variations in a worker is a good idea, but it is not specific to "on create" It would be just as useful for folder moves, for regenerating after a variation is added to the configuration, or for It is not a "no", it is rather "I would prefer that this PR is only centered on the 1st point (generating a varation when a media is created)" For this PR (store on create only), here is what I would like to change The naming of the setting is problematic. It should rather be named The setting should handle multiple scopes: per library (as you did), plus an optional per-variation override following the existing pattern ( The way failures are handled is another point that should be addressed. A conversion failure should be logged and must not make
In practice, this means that the implementation must follow these guidelines:
A few smaller points:
I know this is a fair amount of changes after a long wait on my side. If you are short on time, I can push them to your branch myself, just tell me which you prefer. For the asynchronous part, here is the shape I have in mind - it includes quite a lot of differences compared to the current implementation
This has two consequences on the design : There is one problem I do not want to solve in the bundle yet. Between the upload and the moment the worker has run, the variation file does not exist. This is harmless when the application serves the file, because the For a first version, I would only do three things:
There are some other points to examinate and decisions to take:
If you agree with it, I would like to start a PR on asynchronous management myself, with all the above constraints in mind. In this cas, I would like to have you review it (as you have the real use case), so you could tell if it matches your needs. Does this split work for you? |
The bundle comes from a local filesystem perspective: checking whether a variation exists is cheap, and the application serves the files, so a missing variation can be generated when requested. On a bucket, neither holds. Listing media shouldn't cost a storage request per variation, and URLs served by the bucket itself (pre-signed, a CDN) never reach the application, so a missing variation is never generated.
This adds a
cache.store_on_createsetting, which generates all the variations of a media when it is created or moved. Settingstore_on_create_message_bushands that generation to Symfony Messenger, so it can run in a worker. By default, generation is synchronous and Messenger isn't required.The documentation is in
doc/misc-features/url-generation.rst.